import Vue from 'vue'
import Vuex from 'vuex'

import app from './modules/app'
import user from './modules/user'
import permission from './modules/permission'
import enhance from './modules/enhance'
import online from './modules/online'
import getters from './getters'

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    app,
    user,
    permission,
    enhance,
    online
  },
  state: {
    socketData: [],
    workshopData: {},
    workshopNo: null,
    workShops: [
      { title: '二纺', value: 2 },
      { title: '三纺', value: 3 },
      { title: '五纺', value: 5 },
      { title: '六纺', value: 6 }
    ],
    workshopName: '',
    // company: '1771136798305476610' // 默认当前公司
  },
  mutations: {
    updateSocketData(state, newValue) {
      state.socketData = newValue
    },
    updateWorkshopData(state, newValue) {
      state.workshopData = newValue
      // state.company = newValue.company
    },
    updateWorkshopNo(state, newValue) {
      state.workshopNo = newValue
      for (let i = 0; i < state.workShops.length; i++) {
        state.workshopName = state.workShops[i].title
      }
    }
  },
  actions: {},
  getters
})
